<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8"> 
    <title>考勤</title>
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">   
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="<%=basePath%>js/bootstrap-3.3.7-dist/css/bootstrap.min.css">
	<link rel="stylesheet" href="<%=basePath%>js/confirm/jquery-confirm.min.css"></script>
	<link rel="stylesheet" href="<%=basePath%>css/init.css">
</head>
<body>

<nav class="navbar navbar-default navbar-fixed-top">
	 <div class="col-md-8 col-sm-offset-2 text-center">
	 	<%@include file="/WEB-INF/jsp/public/token.jsp" %>
	  	<form class="navbar-form navbar-center" role="search" id="searchForm" method="post" action="<%=basePath%>sign/list">
	  	  <div class="form-group">
		    <input type="text" class="form-control" id="jobNumber" name="jobNumber" value="${sign.jobNumber}" placeholder="编号">
		  </div>
		  <div class="form-group">
		    <input type="text" class="form-control" id="name" name="name" value="${sign.name}" placeholder="姓名">
		  </div>
		  <button type="button" id="searchBtn" class="btn btn-default">搜索</button>
		  <button type="button" id="clearBtn" class="btn btn-default">清空</button>
		</form>
	</div>
	<div class="text-center init-login">
		<%--  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#excelModal">
		  	<span class="glyphicon glyphicon-save" aria-hidden="true"></span>导出
		 </button>&nbsp;&nbsp;&nbsp;
		 <a href="<%=basePath%>sign/editList" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-cog" aria-hidden="true">编辑</a> --%>
		<!-- Single button -->
		<div class="btn-group">
		  <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		  	<span class="glyphicon glyphicon-list" aria-hidden="true"> 菜单 <span class="caret"></span>
		  </button>
		  <ul class="dropdown-menu">
		    <li>
				<a data-toggle="modal" data-target="#excelModal">
				  	<span class="glyphicon glyphicon-save" aria-hidden="true"></span>导出Excel
				 </a>
			</li>
		    <li role="separator" class="divider"></li>
		    <li>
		    	<a href="<%=basePath%>sign/editList" ><span class="glyphicon glyphicon-cog" aria-hidden="true">编辑列表</span></a>
		    </li>
		     <li role="separator" class="divider"></li>
		    <li>
		    	<a href="<%=basePath%>sign/historyList"  ><span class="glyphicon glyphicon-cog" aria-hidden="true">历史信息查询</span></a>
		    </li>
		    <li role="separator" class="divider"></li>
		    <li>
		    	<a href="<%=basePath%>log/list"  ><span class="glyphicon glyphicon-cog" aria-hidden="true">日志查询</span></a>
		    </li>
			<c:if test="${token!=null&&token!=''}">
				 <li role="separator" class="divider"></li>
				    <li>
						<a data-toggle="modal" data-target="#importExcelModal">
						  	<span class="glyphicon glyphicon-open" aria-hidden="true"></span>导入Excel
						 </a>
					</li>
			</c:if>
			<li role="separator" class="divider"></li>
		    <li>
		    	<a href="<%=basePath%>quartz/list"  ><span class="glyphicon glyphicon-cog" aria-hidden="true">定时调度设置</span></a>
		    </li>
		  </ul>
		</div>
	</div>
</nav>
<div class="container">
	<div class="container-fluid">
		<div class="row"></div>
	</div>
</div>
<script src="<%=basePath%>js/jquery-2.1.1/jquery.min.js"></script>
<script src="<%=basePath%>js/jquery-2.1.1/jquery.form.min.js"></script>
<script src="<%=basePath%>js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
<script src="<%=basePath%>js/web/sgin/index/metaData.js"></script>
<script src="<%=basePath%>js/confirm/jquery-confirm.min.js"></script>
<script src="<%=basePath%>js/web/sgin/index/index.js"></script>
<script type="text/javascript">
var jsonData='${dataJson}';
var selectData='${selectJson}';
MetaData.init('sginList',jsonData,'.row',selectData,1);
function toWorkClick(dataId){
	var selectVal=$("#block"+dataId+" select").val();
	$.ajax({
		url:"signClick",
		data:{dataId:dataId,selectVal:selectVal,dataType:'To'},
		async:false,
		dataType:"json",
		type:"POST",
		success:function(data){
			if(data.status=='success'){
				alertWin("上班操作成功");
			}else{
				alertWin("上班操作失败");
			}
		}
		
	});
}
function offWorkClick(dataId){
	var selectVal=$("#block"+dataId+" select").val();
	$.ajax({
		url:"signClick",
		data:{dataId:dataId,selectVal:selectVal,dataType:'Off'},
		async:false,
		dataType:"json",
		type:"post",
		success:function(data){
			if(data.status=='success'){
				alertWin("下班操作成功");
			}else{
				alertWin("下班操作失败");
			}
		}
	});
}
function alertWin(content){
	$.alert({
	    title: '提示框',
	    content: content,
	    confirm: function(){
	       
	    }
	});
 }
 
 
$(function(){
	$("#clickSuccessBut").click(function(){
		  var statDate=$('#statDate').val();
		  var endDate=$('#endDate').val();
		  var proCode=$('#proCodeId').val();
		  if(statDate=='' || endDate==''){
			  alert("请选择导出日期");
			  return false;
		  }
		  window.location.href='<%=basePath%>sign/export?statDate='+statDate+'&endDate='+endDate+'&proCode='+proCode;
	});
	 var pageindex = 1;
	//滚动加载数据监听
	 $(window).scroll(function () {
	       var scrollTop = $(this).scrollTop();
	       var scrollHeight = $(document).height();
	       var windowHeight = $(this).height();
	       if (scrollTop + windowHeight == scrollHeight) {
	    	   pageindex++;
	    	   MetaData.init('sginList',jsonData,'.row',selectData,pageindex);
	       }
	 });
	 $("#exampleModal").on("hidden.bs.modal", function() {
	        $(this).removeData("bs.modal");
	 });
	 $('#excelModal').on('show.bs.modal', function (event) {
		  var time = new Date().Format("yyyy-MM-dd");
		  var selectJson = eval("("+selectData+")"); 
		  var beanPro="";
		  var optionText='<option value="">全部</option>';
		  for(var key in selectJson){
			beanPro=selectJson[key];
			optionText+='<option value="'+beanPro.projectCode+'">'+beanPro.projectName+'</option>';
		  }
		  var selectHtml='<select style="width:64%;height:25px;" id="proCodeId">'+optionText+'</select>';
		  var htmlText ='<div class="text-center">选择项目：'+selectHtml+'<br/><br/>开始日期：<input type="text" class="Wdate" onClick="WdatePicker()" id="statDate" value="'+time+'" style="height:25px;"/><br/><br/>结束日期：<input type="text" class="Wdate" onClick="WdatePicker()" id="endDate" value="'+time+'" style="height:25px;"/></div>';
		  var modal = $(this)
		  modal.find('.modal-title').text("导出提示框");
		  modal.find('.modal-body').html(htmlText)
	 });
	
	 $('#importExcelModal').on('show.bs.modal', function (event) {
		  var optionText='<option value="SIGN" selected="selected">员工信息导入</option>';
		  var selectHtml='<select style="width:54%;height:25px;" id="impCodeId">'+optionText+'</select>';
		  var htmlText ='<form method="POST"  enctype="multipart/form-data" id="signform1" action=""><div class="text-center">选择导入类型：'+selectHtml+'<br/><br/>选择导入文件：<input id="singUpfile" type="file" name="upfile"></div></form>';
		  var modal = $(this)
		  modal.find('.modal-title').text("导入提示框");
		  modal.find('.modal-body').html(htmlText)
	 });
	 $("#impSuccessBut").click(function(){
		 if(checkData()){  
             $('#signform1').ajaxSubmit({    
                 url:'<%=basePath%>sign/ajaxUpload',  
                 dataType: 'text',  
                 success: resutlMsg,  
                 error: errorMsg  
             });   
             function resutlMsg(msg){  
                 alert(msg);     
                 $("#singUpfile").val("");  
             }  
             function errorMsg(){   
                 alert("导入excel出错！");      
             }  
         }  
	 });
});
//JS校验form表单信息  
function checkData(){  
   var fileDir = $("#singUpfile").val();  
   var suffix = fileDir.substr(fileDir.lastIndexOf("."));  
   if("" == fileDir){  
       alert("选择需要导入的Excel文件！");  
       return false;  
   }  
   if(".xls" != suffix && ".xlsx" != suffix ){  
       alert("选择Excel格式的文件导入！");  
       return false;  
   }  
   return true;  
}  
</script>
</body>
</html>
